package ProjectViewer;

import java.awt.Color;

import javax.swing.JLabel;
import javax.swing.JPanel;
//import javax.swing.ListModel;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
//import javax.swing.event.ListDataListener;
//import javax.swing.event.ListSelectionEvent;
//import javax.swing.event.ListSelectionListener;

import System.Settings_System;

import ClassData.ClassData;
//import ClassData.ConstantPoolInfo;

public class Panel_ClassData extends JPanel {

	private static final long serialVersionUID = 1L;
	JLabel classNameLabel;
	JLabel superClassNameLabel;
	JLabel majorVersionLabel;
	JLabel minorVersionLabel;
	JLabel interfacesLabel;
	JLabel fieldsLabel;
	JLabel methodsLabel;
	JLabel flagsLabel;
	JLabel attributes;

	JLabel staticData;
	JLabel dynamicData;
	JLabel staticInheritedData;
	JLabel dynamicInheritedData;

	private static final String [] [] MessageName =
	{{"Class data","Class name","Superclass name","Major version","Minor version","Flags","Interfaces","Fields","Methods",
		"Data size","Own","Inherited","Static","Dynamic"},
	{"Klassendaten","Klassenname","Name der Oberklasse","Major version","Minor version","Flags","Interfaces","Felder","Methoden"}};	
	
	private static final int String_PanelNameID			=0;
	private static final int String_ClasNameID			=String_PanelNameID+1; 
	private static final int String_SuperClasNameID		=String_ClasNameID+1; 
	private static final int String_MajorVersionID		=String_SuperClasNameID+1; 
	private static final int String_MinorVersionID		=String_MajorVersionID+1;
	private static final int String_FlagsID				=String_MinorVersionID+1;
	
	private static final int String_InterfacesID		=String_FlagsID+1; 
	private static final int String_FieldsID			=String_InterfacesID+1; 
	private static final int String_MethodsID			=String_FieldsID+1;
	private static final int String_DataSizeID			=String_MethodsID+1;
	private static final int String_OwnID				=String_DataSizeID+1;
	private static final int String_InheritedID			=String_OwnID+1;
	
	private static final int String_StaticID			=String_InheritedID+1;
	private static final int String_DynamicID			=String_StaticID+1;

/*
 * 	private short minor_version;
	private short major_version;
 

	private ConstantPoolInfo constantPool[]; 

	private short access_flags;
	private short this_class;
	private short super_class;

 */
	public Panel_ClassData() {
		build();
	}

	private void build() {
		JLabel tmpLabel;
	
	setBorder(new TitledBorder(new LineBorder(Color.black,2),MessageName [Settings_System.GetActiveLanguage()] [String_ClasNameID]));
	setLayout(null);

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_ClasNameID]) ;
	tmpLabel.setBounds(20,20,100,20);
	add(tmpLabel);
	
	classNameLabel= new JLabel();
	classNameLabel.setBounds(130,20,400,20);
	add(classNameLabel);
	

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_SuperClasNameID]) ;
	tmpLabel.setBounds(20,40,100,20);
	add(tmpLabel);

	superClassNameLabel= new JLabel();
	superClassNameLabel.setBounds(130,40,400,20);
	add(superClassNameLabel);
	

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_MajorVersionID]) ;
	tmpLabel.setBounds(20,60,100,20);
	add(tmpLabel);
	
	majorVersionLabel= new JLabel();
	majorVersionLabel.setBounds(130,60,40,20);
	add(majorVersionLabel);

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_MinorVersionID]) ;
	tmpLabel.setBounds(180,60,180,20);
	add(tmpLabel);
	
	minorVersionLabel= new JLabel();
	minorVersionLabel.setBounds(300,60,40,20);
	add(minorVersionLabel);


		tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_FlagsID]) ;
	tmpLabel.setBounds(20,80,180,20);
	add(tmpLabel);
	
	flagsLabel= new JLabel();
	flagsLabel.setBounds(120,80,200,20);
	add(flagsLabel);
	

	
	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_InterfacesID]) ;
	tmpLabel.setBounds(20,100,100,20);
	add(tmpLabel);

	interfacesLabel=new JLabel();
	interfacesLabel.setBounds(120,100,40,20);
	add(interfacesLabel);

	
	
	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_FieldsID]) ;
	tmpLabel.setBounds(160,100,100,20);
	add(tmpLabel);

	
	fieldsLabel=new JLabel();
	fieldsLabel.setBounds(260,100,40,20);
	add(fieldsLabel);

	
	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_MethodsID]) ;
	tmpLabel.setBounds(300,100,100,20);
	add(tmpLabel);

	methodsLabel=new JLabel();	
	methodsLabel.setBounds(400,100,40,20);
	add(methodsLabel);

	JPanel tmpPanel;
	tmpPanel= new JPanel();
	tmpPanel.setBorder(new TitledBorder(new LineBorder(Color.black,2),MessageName [Settings_System.GetActiveLanguage()] [String_DataSizeID]));
	tmpPanel.setLayout(null);
	tmpPanel.setBounds(5, 120, 500, 60);
	add(tmpPanel);

	
	
//	private static final int String_OwnID						=String_DataSizeID+1;
//	private static final int String_InheritedID	

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_OwnID]) ;
	tmpLabel.setBounds(10,10,100,20);
	tmpPanel.add(tmpLabel);

	
	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_StaticID]) ;
	tmpLabel.setBounds(110,10,100,20);
	tmpPanel.add(tmpLabel);

	staticData=new JLabel();	
	staticData.setBounds(210,10,40,20);
	tmpPanel.add(staticData);

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_DynamicID]) ;
	tmpLabel.setBounds(250,10,100,20);
	tmpPanel.add(tmpLabel);

	dynamicData=new JLabel();	
	dynamicData.setBounds(350,10,40,20);
	tmpPanel.add(dynamicData);
	

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_InheritedID]) ;
	tmpLabel.setBounds(10,30,100,20);
	tmpPanel.add(tmpLabel);

	
	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_StaticID]) ;
	tmpLabel.setBounds(110,30,100,20);
	tmpPanel.add(tmpLabel);

	staticInheritedData=new JLabel();	
	staticInheritedData.setBounds(210,30,40,20);
	tmpPanel.add(staticInheritedData);

	tmpLabel= new JLabel(MessageName [Settings_System.GetActiveLanguage()] [String_DynamicID]) ;
	tmpLabel.setBounds(250,30,100,20);
	tmpPanel.add(tmpLabel);

	dynamicInheritedData=new JLabel();	
	dynamicInheritedData.setBounds(350,30,40,20);
	tmpPanel.add(dynamicInheritedData);
	
	
	/*
	 * JLabel staticData;
JLabel dynamicData;
JLabel staticInheritedData;
JLabel dynamicInheritedData;
	 */
	
}

	public void displayClass(ClassData classToDisplay) {

		classNameLabel.setText(classToDisplay.getClassName());
		superClassNameLabel.setText(classToDisplay.getSuperClassName());
	
		//interfacesLabel.setText(classToDisplay.);
		majorVersionLabel.setText(String.valueOf(classToDisplay.getMajorVersion()));
		minorVersionLabel.setText(String.valueOf(classToDisplay.getMinorVersion()));
	
		interfacesLabel.setText(String.valueOf(classToDisplay.getInterfacesCount()));
	
		fieldsLabel.setText(String.valueOf(classToDisplay.getFieldsCount()));
		methodsLabel.setText(String.valueOf(classToDisplay.getMethodsCount()));
	
	
		flagsLabel.setText(classToDisplay.getAccesFlagsAsString());
		//JLabel flagsLabel;
		//JLabel attributes;
		
		staticData.setText(String.valueOf(classToDisplay.getStaticDataSize()));
		dynamicData.setText(String.valueOf(classToDisplay.getInstanceDataSize()));
		 
		staticInheritedData.setText(String.valueOf(classToDisplay.getInheritedStaticDataSize()));
		dynamicInheritedData.setText(String.valueOf(classToDisplay.getIinheritedInstanceDataSize()));
	 
	}
}